<?php
include"../inc/config.inc.php";

$id = $_POST['id'];
for($i=0; $i<count($id); $i++)
{
    $sql = "SELECT level_id"
        ." FROM student"
        ." WHERE std_id = '".$id[$i]."'";
    $result = mysql_query($sql);
    $row = mysql_fetch_object($result);
    $arr1 = str_split($row->level_id);
    $number = (int) $arr1[1];
    if($arr1[1] < 6)
    {
        $new_level = "L".($number+1);
    }
    else
    {
        $new_level = $row->level_id;
    }
    $sql_update = "UPDATE student set level_id = '".$new_level."'  WHERE std_id = '".$id[$i]."'";
    mysql_query($sql_update);
}// End foreach

echo"<meta http-equiv='refresh' content='0;URL=student.php'>";
?>